home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / m2cmp20 / realconv.def < prev    next >
Text File  |  1988-11-19  |  2KB  |  51 lines

  1. DEFINITION MODULE RealConversions;
  2.  
  3. (* (C) Copyright 1987,1988 Fitted Software Tools. All rights reserved. *)
  4.  
  5.  
  6. PROCEDURE RealToString( x :REAL; decDigits, n :INTEGER;
  7.                         VAR s :ARRAY OF CHAR; VAR ok :BOOLEAN );
  8. (*
  9.     Converts x to an ASCII representation.
  10.     n is the width of the ASCII field.
  11.     ABS(decDigits) is the number of decimal digits desired.
  12.     s is where the result is placed.
  13.     ok is set to TRUE is the conversion was successful.
  14.  
  15.     The output in s is in fixed point notation if decDigits is positive;
  16.     otherwise, x is represented in scientific notation.
  17.  
  18.     If n is greater than the number of characters needed for the conversion,
  19.     s is padded with spaces on the left.
  20.     If decDigits > 0 then n must be >= decDigits+2
  21.     else n must be >= ABS(decDigits)+7
  22.  
  23.     Examples:
  24.  
  25.         RealToString( 1.148, 2, 6, s, ok ) would place in s:
  26.             "  1.15"
  27.  
  28.         RealToString( 1.148, -2, 10, s, ok ) would place in s:
  29.             "  1.15E+00"
  30. *)
  31.  
  32. PROCEDURE StringToReal( s :ARRAY OF CHAR; VAR x :REAL; VAR ok :BOOLEAN );
  33. (*
  34.     converts the string s into a REAL number.
  35.     a real in the format defined for Modula-2 REAL literals is expected.
  36. *)
  37.  
  38. PROCEDURE LongRealToString( x :LONGREAL; decDigits, n :INTEGER;
  39.                             VAR s :ARRAY OF CHAR; VAR ok :BOOLEAN );
  40. (*
  41.     works like RealToString
  42. *)
  43.  
  44. PROCEDURE StringToLongReal( s :ARRAY OF CHAR;
  45.                             VAR x :LONGREAL; VAR ok :BOOLEAN );
  46. (*
  47.     works like StringToReal
  48. *)
  49.  
  50.  
  51. END RealConversions.